package com.jcode222.mappings;

import com.jcode222.entity.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface UserMapping {

    UserMapping INSTANCE = Mappers.getMapper(UserMapping.class);

    /**
     * java: No property named "id" exists in source parameter(s). Type "User" has no properties.
     * 原因：加载顺序问题，可能导致mapstruct先执行
     */
    @Mappings({
            @Mapping(source = "id", target = "userId"),
            @Mapping(source = "name", target = "userName"),
    })
    UserDto userToUserDto(User user);
}
